import basic from './basic.js';
var actmodel = new basic();
// var actmodel={};
actmodel.geturl = function (source,type) {
  if(!source)
  {
    source="film";
  }
   
  var app = getApp();
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/api_jtklm',
      showLoading: true,      
      'data': { "op": "geturl",plugin:'smapi',source,type},
      'method': "post",
      success: function (res) {
        resolve(res.data.data);  
      },
      fail: function (res) {
        resolve({ status: -1, "message": "操作失败2" });
      },
      complete: function () {
      }
    });
  })
} 
actmodel.getacturl = function (actid) {
  var app = getApp();
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/api_jtklm',
      showLoading: true,      
      'data': { "op": "getacturl",plugin:'smapi',actid},
      'method': "post",
      success: function (res) {
        resolve(res.data.data);  
      },
      fail: function (res) {
        resolve({ status: -1, "message": "操作失败2" });
      },
      complete: function () {
      }
    });
  })
} 
actmodel.createorder = function (type,data) {

  
  if(!type)
  {
    type="film";
  }
  console.log(type) 
  console.log(data) 

  // return ;

  var app = getApp();
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/api_jtklm',
      showLoading: true,      
      'data': { "op": "createorder",plugin:'smapi',type,data:JSON.stringify(data)},
      'method': "post",
      success: function (res) {
        resolve(res.data.data);  
      },
      fail: function (res) {
        resolve({ status: -1, "message": "操作失败" });
      },
      complete: function () {
      }
    });
  })
} 
actmodel.getorderinfo = function (type,orderNo) {
  if(!type)
  {
    type="film";
  }
   
  var app = getApp();
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/api_jtklm',
      showLoading: true,      
      'data': { "op": "getorderinfo",plugin:'smapi',type,orderNo},
      'method': "post",
      success: function (res) {
        resolve(res.data.data);  
      },
      fail: function (res) {
        resolve({ status: -1, "message": "操作失败" });
      },
      complete: function () {
      }
    });
  })
} 
actmodel.list = function (strtype) {
  if(!strtype)
  {
    strtype=""
  }
   
  var app = getApp();
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/api_huka',
      showLoading: false,      
      'data': { "op": "list",plugin:'smapi',strtype },
      'method': "post",
      success: function (res) {
 
                 
        resolve(res.data.data);
     
      },
      fail: function (res) {
        resolve({ status: -1, "message": "操作失败2" });
      },
      complete: function () {
      }
    });
  })
} 


actmodel.getactmodel = function (id) {
 
   
  var app = getApp();
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/api_jtklm',
      showLoading: true,      
      'data': { "op": "getactmodel",plugin:'smapi' ,id},
      'method': "post",
      success: function (res) {
     
        resolve(res.data.data);
      
      },
      fail: function (res) {
        resolve({ status: -1, "message": "操作失败2" });
      },
      complete: function () {
      }
    });
  })
} 
actmodel.getmodel = function (id,strtype) {
  if(!strtype)
  {
    strtype=""
  }
   
  var app = getApp();
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/api_huka',
      showLoading: true,      
      'data': { "op": "getmodel",plugin:'smapi',strtype ,id},
      'method': "post",
      success: function (res) {

        resolve(res.data.data);
   
      },
      fail: function (res) {
        resolve({ status: -1, "message": "操作失败2" });
      },
      complete: function () {
      }
    });
  })
} 

// actmodel.createorder = function (model) {
//   var app = getApp();
//   var data = { "op": "createorder",plugin:'api', model: model }
//   return new Promise((resolve, reject) => {
//     app.util.request({
//       'url': 'entry/wxapp/api_huka',
//       'data': data,
//       'method': "get",
//       success: function (res) {
//         if (res.data.errno == 0) {

//           resolve(res.data.data);

//         }
//         reject(res.data.message);
//       },
//       fail: function (res) {

//         reject(((res.data && res.data.message) ? res.data.message : res.errMsg));
//       },
//       complete: function () {
//       }
//     });
//   });
// }
actmodel.queryorder=function (id) {

  var app = getApp();
  var data = { "op": "queryorder", id: id,plugin:'smapi'}
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/api_huka',
      'data': data,
      'method': "post",
      success: function (res) {
        
        resolve(res.data.data);
      }
    })
})
}

actmodel.sendnotice=function (ordernum) {

  var app = getApp();
  var data = { "op": "sendnotice", ordernum: ordernum,plugin:'smapi'}
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/api_huka',
      'data': data,
      'method': "post",
      success: function (res) {
        
        resolve(res.data.data);
      }
    })
})
}
module.exports = actmodel;
